package org.dftproject.genesis.ui.figures;

import org.eclipse.draw2d.FigureCanvas;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;

public class FigureCanvasEx extends FigureCanvas {

	public FigureCanvasEx(Composite parent) {
		super(parent);
		
		addMouseListener(new MouseListener() {

			public void mouseDoubleClick(MouseEvent e) {
			}

			public void mouseDown(MouseEvent e) {
				setFocus();
			}

			public void mouseUp(MouseEvent e) {
			}
			
		});
		setTabList(new Control[0]);
		getLightweightSystem().setEventDispatcher(new SWTEventDispatcherEx());
	}
	
	@Override
	public boolean setFocus() {
		if ((getStyle() & SWT.NO_FOCUS) != 0)
			return super.setFocus();
		return forceFocus();
	}

}
